﻿// Type: System.Type
// Assembly: mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
// Assembly location: C:\Windows\Microsoft.NET\Framework\v4.0.30319\mscorlib.dll

using System.Collections;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Threading;

namespace System
{
  [ClassInterface(ClassInterfaceType.None)]
  [ComDefaultInterface(typeof (_Type))]
  [ComVisible(true)]
  [Serializable]
  public abstract class Type : MemberInfo, _Type, IReflect
  {
    public static readonly object Missing = (object) Missing.Value;
    public static readonly char Delimiter = '.';
    public static readonly Type[] EmptyTypes = new Type[0];
    private const BindingFlags DefaultLookup = 28;
    public static readonly MemberFilter FilterAttribute;
    public static readonly MemberFilter FilterName;
    public static readonly MemberFilter FilterNameIgnoreCase;
    private static Binder defaultBinder;

    public override MemberTypes MemberType
    {
      get
      {
        return MemberTypes.TypeInfo;
      }
    }

    public override Type DeclaringType
    {
      get
      {
        return (Type) null;
      }
    }

    public virtual MethodBase DeclaringMethod
    {
      get
      {
        return (MethodBase) null;
      }
    }

    public override Type ReflectedType
    {
      get
      {
        return (Type) null;
      }
    }

    public virtual StructLayoutAttribute StructLayoutAttribute
    {
      get
      {
        throw new NotSupportedException();
      }
    }

    public abstract Guid GUID { get; }

    public static Binder DefaultBinder
    {
      [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] get
      {
        if (Type.defaultBinder == null)
          Type.CreateBinder();
        return Type.defaultBinder;
      }
    }

    public new abstract Module Module { get; }

    public abstract Assembly Assembly { get; }

    public virtual RuntimeTypeHandle TypeHandle
    {
      get
      {
        throw new NotSupportedException();
      }
    }

    public abstract string FullName { get; }

    public abstract string Namespace { get; }

    public abstract string AssemblyQualifiedName { get; }

    public abstract Type BaseType { get; }

    [ComVisible(true)]
    public ConstructorInfo TypeInitializer
    {
      get
      {
        return this.GetConstructorImpl(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic, (Binder) null, CallingConventions.Standard | CallingConventions.VarArgs, Type.EmptyTypes, (ParameterModifier[]) null);
      }
    }

    public bool IsNested
    {
      [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] get
      {
        return this.DeclaringType != (Type) null;
      }
    }

    public TypeAttributes Attributes
    {
      get
      {
        return this.GetAttributeFlagsImpl();
      }
    }

    public virtual GenericParameterAttributes GenericParameterAttributes
    {
      get
      {
        throw new NotSupportedException();
      }
    }

    public bool IsVisible
    {
      [SecuritySafeCritical] get
      {
        RuntimeType type1 = this as RuntimeType;
        if (type1 != (RuntimeType) null)
          return RuntimeTypeHandle.IsVisible(type1);
        if (this.IsGenericParameter)
          return true;
        if (this.HasElementType)
          return this.GetElementType().IsVisible;
        Type type2;
        for (type2 = this; type2.IsNested; type2 = type2.DeclaringType)
        {
          if (!type2.IsNestedPublic)
            return false;
        }
        if (!type2.IsPublic)
          return false;
        if (this.IsGenericType && !this.IsGenericTypeDefinition)
        {
          foreach (Type type3 in this.GetGenericArguments())
          {
            if (!type3.IsVisible)
              return false;
          }
        }
        return true;
      }
    }

    public bool IsNotPublic
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == TypeAttributes.NotPublic;
      }
    }

    public bool IsPublic
    {
      [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == TypeAttributes.Public;
      }
    }

    public bool IsNestedPublic
    {
      [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == TypeAttributes.NestedPublic;
      }
    }

    public bool IsNestedPrivate
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == (TypeAttributes.Public | TypeAttributes.NestedPublic);
      }
    }

    public bool IsNestedFamily
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == TypeAttributes.NestedFamily;
      }
    }

    public bool IsNestedAssembly
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == (TypeAttributes.Public | TypeAttributes.NestedFamily);
      }
    }

    public bool IsNestedFamANDAssem
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == (TypeAttributes.NestedPublic | TypeAttributes.NestedFamily);
      }
    }

    public bool IsNestedFamORAssem
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.VisibilityMask) == TypeAttributes.VisibilityMask;
      }
    }

    public bool IsAutoLayout
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.LayoutMask) == TypeAttributes.NotPublic;
      }
    }

    public bool IsLayoutSequential
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.LayoutMask) == TypeAttributes.SequentialLayout;
      }
    }

    public bool IsExplicitLayout
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.LayoutMask) == TypeAttributes.ExplicitLayout;
      }
    }

    public bool IsClass
    {
      get
      {
        if ((this.GetAttributeFlagsImpl() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.NotPublic)
          return !this.IsValueType;
        else
          return false;
      }
    }

    public bool IsInterface
    {
      [SecuritySafeCritical] get
      {
        RuntimeType type = this as RuntimeType;
        if (type != (RuntimeType) null)
          return RuntimeTypeHandle.IsInterface(type);
        else
          return (this.GetAttributeFlagsImpl() & TypeAttributes.ClassSemanticsMask) == TypeAttributes.ClassSemanticsMask;
      }
    }

    public bool IsValueType
    {
      get
      {
        return this.IsValueTypeImpl();
      }
    }

    public bool IsAbstract
    {
      [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.Abstract) != TypeAttributes.NotPublic;
      }
    }

    public bool IsSealed
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.Sealed) != TypeAttributes.NotPublic;
      }
    }

    public virtual bool IsEnum
    {
      [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")] get
      {
        return this.IsSubclassOf((Type) RuntimeType.EnumType);
      }
    }

    public bool IsSpecialName
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.SpecialName) != TypeAttributes.NotPublic;
      }
    }

    public bool IsImport
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.Import) != TypeAttributes.NotPublic;
      }
    }

    public virtual bool IsSerializable
    {
      get
      {
        if ((this.GetAttributeFlagsImpl() & TypeAttributes.Serializable) != TypeAttributes.NotPublic)
          return true;
        RuntimeType runtimeType = this.UnderlyingSystemType as RuntimeType;
        if (runtimeType != (RuntimeType) null)
          return runtimeType.IsSpecialSerializableType();
        else
          return false;
      }
    }

    public bool IsAnsiClass
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.StringFormatMask) == TypeAttributes.NotPublic;
      }
    }

    public bool IsUnicodeClass
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.StringFormatMask) == TypeAttributes.UnicodeClass;
      }
    }

    public bool IsAutoClass
    {
      get
      {
        return (this.GetAttributeFlagsImpl() & TypeAttributes.StringFormatMask) == TypeAttributes.AutoClass;
      }
    }

    public bool IsArray
    {
      get
      {
        return this.IsArrayImpl();
      }
    }

    internal virtual bool IsSzArray
    {
      get
      {
        return false;
      }
    }

    public virtual bool IsGenericType
    {
      get
      {
        return false;
      }
    }

    public virtual bool IsGenericTypeDefinition
    {
      get
      {
        return false;
      }
    }

    public virtual bool IsGenericParameter
    {
      get
      {
        return false;
      }
    }

    public virtual int GenericParameterPosition
    {
      get
      {
        throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter"));
      }
    }

    public virtual bool ContainsGenericParameters
    {
      get
      {
        if (this.HasElementType)
          return this.GetRootElementType().ContainsGenericParameters;
        if (this.IsGenericParameter)
          return true;
        if (!this.IsGenericType)
          return false;
        foreach (Type type in this.GetGenericArguments())
        {
          if (type.ContainsGenericParameters)
            return true;
        }
        return false;
      }
    }

    public bool IsByRef
    {
      get
      {
        return this.IsByRefImpl();
      }
    }

    public bool IsPointer
    {
      get
      {
        return this.IsPointerImpl();
      }
    }

    public bool IsPrimitive
    {
      get
      {
        return this.IsPrimitiveImpl();
      }
    }

    public bool IsCOMObject
    {
      get
      {
        return this.IsCOMObjectImpl();
      }
    }

    public bool HasElementType
    {
      get
      {
        return this.HasElementTypeImpl();
      }
    }

    public bool IsContextful
    {
      get
      {
        return this.IsContextfulImpl();
      }
    }

    public bool IsMarshalByRef
    {
      get
      {
        return this.IsMarshalByRefImpl();
      }
    }

    internal bool HasProxyAttribute
    {
      get
      {
        return this.HasProxyAttributeImpl();
      }
    }

    internal virtual bool IsRuntimeType
    {
      get
      {
        return false;
      }
    }

    public virtual bool IsSecurityCritical
    {
      get
      {
        throw new NotImplementedException();
      }
    }

    public virtual bool IsSecuritySafeCritical
    {
      get
      {
        throw new NotImplementedException();
      }
    }

    public virtual bool IsSecurityTransparent
    {
      get
      {
        throw new NotImplementedException();
      }
    }

    internal bool NeedsReflectionSecurityCheck
    {
      get
      {
        if (!this.IsVisible || this.IsSecurityCritical && !this.IsSecuritySafeCritical)
          return true;
        if (this.IsGenericType)
        {
          foreach (Type type in this.GetGenericArguments())
          {
            if (type.NeedsReflectionSecurityCheck)
              return true;
          }
        }
        else if (this.IsArray || this.IsPointer)
          return this.GetElementType().NeedsReflectionSecurityCheck;
        return false;
      }
    }

    public abstract Type UnderlyingSystemType { get; }

    static Type()
    {
      System.__Filters filters = new System.__Filters();
      Type.FilterAttribute = new MemberFilter(filters.FilterAttribute);
      Type.FilterName = new MemberFilter(filters.FilterName);
      Type.FilterNameIgnoreCase = new MemberFilter(filters.FilterIgnoreCase);
    }

    [SecuritySafeCritical]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static bool operator ==(Type left, Type right);

    [SecuritySafeCritical]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static bool operator !=(Type left, Type right);

    public new Type GetType()
    {
      return base.GetType();
    }

    [SecuritySafeCritical]
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type GetType(string typeName, bool throwOnError, bool ignoreCase)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return (Type) RuntimeType.GetType(typeName, throwOnError, ignoreCase, false, ref stackMark);
    }

    [SecuritySafeCritical]
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type GetType(string typeName, bool throwOnError)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return (Type) RuntimeType.GetType(typeName, throwOnError, false, false, ref stackMark);
    }

    [SecuritySafeCritical]
    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type GetType(string typeName)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return (Type) RuntimeType.GetType(typeName, false, false, false, ref stackMark);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, false, false, ref stackMark);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, throwOnError, false, ref stackMark);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type GetType(string typeName, Func<AssemblyName, Assembly> assemblyResolver, Func<Assembly, string, bool, Type> typeResolver, bool throwOnError, bool ignoreCase)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return TypeNameParser.GetType(typeName, assemblyResolver, typeResolver, throwOnError, ignoreCase, ref stackMark);
    }

    [MethodImpl(MethodImplOptions.NoInlining)]
    public static Type ReflectionOnlyGetType(string typeName, bool throwIfNotFound, bool ignoreCase)
    {
      StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
      return (Type) RuntimeType.GetType(typeName, throwIfNotFound, ignoreCase, true, ref stackMark);
    }

    public virtual Type MakePointerType()
    {
      throw new NotSupportedException();
    }

    public virtual Type MakeByRefType()
    {
      throw new NotSupportedException();
    }

    public virtual Type MakeArrayType()
    {
      throw new NotSupportedException();
    }

    public virtual Type MakeArrayType(int rank)
    {
      throw new NotSupportedException();
    }

    [SecurityCritical]
    public static Type GetTypeFromProgID(string progID)
    {
      return RuntimeType.GetTypeFromProgIDImpl(progID, (string) null, false);
    }

    [SecurityCritical]
    public static Type GetTypeFromProgID(string progID, bool throwOnError)
    {
      return RuntimeType.GetTypeFromProgIDImpl(progID, (string) null, throwOnError);
    }

    [SecurityCritical]
    public static Type GetTypeFromProgID(string progID, string server)
    {
      return RuntimeType.GetTypeFromProgIDImpl(progID, server, false);
    }

    [SecurityCritical]
    public static Type GetTypeFromProgID(string progID, string server, bool throwOnError)
    {
      return RuntimeType.GetTypeFromProgIDImpl(progID, server, throwOnError);
    }

    [SecuritySafeCritical]
    public static Type GetTypeFromCLSID(Guid clsid)
    {
      return RuntimeType.GetTypeFromCLSIDImpl(clsid, (string) null, false);
    }

    [SecuritySafeCritical]
    public static Type GetTypeFromCLSID(Guid clsid, bool throwOnError)
    {
      return RuntimeType.GetTypeFromCLSIDImpl(clsid, (string) null, throwOnError);
    }

    [SecuritySafeCritical]
    public static Type GetTypeFromCLSID(Guid clsid, string server)
    {
      return RuntimeType.GetTypeFromCLSIDImpl(clsid, server, false);
    }

    [SecuritySafeCritical]
    public static Type GetTypeFromCLSID(Guid clsid, string server, bool throwOnError)
    {
      return RuntimeType.GetTypeFromCLSIDImpl(clsid, server, throwOnError);
    }

    internal string SigToString()
    {
      Type type = this;
      while (type.HasElementType)
        type = type.GetElementType();
      if (type.IsNested)
        return this.Name;
      string str = this.ToString();
      if (type.IsPrimitive || type == typeof (void) || type == typeof (TypedReference))
        str = str.Substring("System.".Length);
      return str;
    }

    public static TypeCode GetTypeCode(Type type)
    {
      if (type == (Type) null)
        return TypeCode.Empty;
      else
        return type.GetTypeCodeImpl();
    }

    protected virtual TypeCode GetTypeCodeImpl()
    {
      if (this != this.UnderlyingSystemType && this.UnderlyingSystemType != (Type) null)
        return Type.GetTypeCode(this.UnderlyingSystemType);
      else
        return TypeCode.Object;
    }

    private static void CreateBinder()
    {
      if (Type.defaultBinder != null)
        return;
      DefaultBinder defaultBinder = new DefaultBinder();
      Interlocked.CompareExchange<Binder>(ref Type.defaultBinder, (Binder) defaultBinder, (Binder) null);
    }

    public abstract object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, ParameterModifier[] modifiers, CultureInfo culture, string[] namedParameters);

    [DebuggerHidden]
    [DebuggerStepThrough]
    public object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args, CultureInfo culture)
    {
      return this.InvokeMember(name, invokeAttr, binder, target, args, (ParameterModifier[]) null, culture, (string[]) null);
    }

    [DebuggerStepThrough]
    [DebuggerHidden]
    public object InvokeMember(string name, BindingFlags invokeAttr, Binder binder, object target, object[] args)
    {
      return this.InvokeMember(name, invokeAttr, binder, target, args, (ParameterModifier[]) null, (CultureInfo) null, (string[]) null);
    }

    internal virtual RuntimeTypeHandle GetTypeHandleInternal()
    {
      return this.TypeHandle;
    }

    public static RuntimeTypeHandle GetTypeHandle(object o)
    {
      if (o == null)
        throw new ArgumentNullException((string) null, Environment.GetResourceString("Arg_InvalidHandle"));
      else
        return new RuntimeTypeHandle((RuntimeType) o.GetType());
    }

    [SecurityCritical]
    [MethodImpl(MethodImplOptions.InternalCall)]
    internal static RuntimeType GetTypeFromHandleUnsafe(IntPtr handle);

    [SecuritySafeCritical]
    [MethodImpl(MethodImplOptions.InternalCall)]
    public static Type GetTypeFromHandle(RuntimeTypeHandle handle);

    public virtual int GetArrayRank()
    {
      throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
    }

    [ComVisible(true)]
    public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
    {
      if (types == null)
        throw new ArgumentNullException("types");
      for (int index = 0; index < types.Length; ++index)
      {
        if (types[index] == (Type) null)
          throw new ArgumentNullException("types");
      }
      return this.GetConstructorImpl(bindingAttr, binder, callConvention, types, modifiers);
    }

    [ComVisible(true)]
    public ConstructorInfo GetConstructor(BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
    {
      if (types == null)
        throw new ArgumentNullException("types");
      for (int index = 0; index < types.Length; ++index)
      {
        if (types[index] == (Type) null)
          throw new ArgumentNullException("types");
      }
      return this.GetConstructorImpl(bindingAttr, binder, CallingConventions.Standard | CallingConventions.VarArgs, types, modifiers);
    }

    [ComVisible(true)]
    public ConstructorInfo GetConstructor(Type[] types)
    {
      return this.GetConstructor(BindingFlags.Instance | BindingFlags.Public, (Binder) null, types, (ParameterModifier[]) null);
    }

    protected abstract ConstructorInfo GetConstructorImpl(BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers);

    [ComVisible(true)]
    public ConstructorInfo[] GetConstructors()
    {
      return this.GetConstructors(BindingFlags.Instance | BindingFlags.Public);
    }

    [ComVisible(true)]
    public abstract ConstructorInfo[] GetConstructors(BindingFlags bindingAttr);

    public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      for (int index = 0; index < types.Length; ++index)
      {
        if (types[index] == (Type) null)
          throw new ArgumentNullException("types");
      }
      return this.GetMethodImpl(name, bindingAttr, binder, callConvention, types, modifiers);
    }

    public MethodInfo GetMethod(string name, BindingFlags bindingAttr, Binder binder, Type[] types, ParameterModifier[] modifiers)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      for (int index = 0; index < types.Length; ++index)
      {
        if (types[index] == (Type) null)
          throw new ArgumentNullException("types");
      }
      return this.GetMethodImpl(name, bindingAttr, binder, CallingConventions.Standard | CallingConventions.VarArgs, types, modifiers);
    }

    public MethodInfo GetMethod(string name, Type[] types, ParameterModifier[] modifiers)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      for (int index = 0; index < types.Length; ++index)
      {
        if (types[index] == (Type) null)
          throw new ArgumentNullException("types");
      }
      return this.GetMethodImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, CallingConventions.Standard | CallingConventions.VarArgs, types, modifiers);
    }

    public MethodInfo GetMethod(string name, Type[] types)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      for (int index = 0; index < types.Length; ++index)
      {
        if (types[index] == (Type) null)
          throw new ArgumentNullException("types");
      }
      return this.GetMethodImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, CallingConventions.Standard | CallingConventions.VarArgs, types, (ParameterModifier[]) null);
    }

    public MethodInfo GetMethod(string name, BindingFlags bindingAttr)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      else
        return this.GetMethodImpl(name, bindingAttr, (Binder) null, CallingConventions.Standard | CallingConventions.VarArgs, (Type[]) null, (ParameterModifier[]) null);
    }

    public MethodInfo GetMethod(string name)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      else
        return this.GetMethodImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, CallingConventions.Standard | CallingConventions.VarArgs, (Type[]) null, (ParameterModifier[]) null);
    }

    protected abstract MethodInfo GetMethodImpl(string name, BindingFlags bindingAttr, Binder binder, CallingConventions callConvention, Type[] types, ParameterModifier[] modifiers);

    public MethodInfo[] GetMethods()
    {
      return this.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract MethodInfo[] GetMethods(BindingFlags bindingAttr);

    public abstract FieldInfo GetField(string name, BindingFlags bindingAttr);

    public FieldInfo GetField(string name)
    {
      return this.GetField(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public FieldInfo[] GetFields()
    {
      return this.GetFields(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract FieldInfo[] GetFields(BindingFlags bindingAttr);

    public Type GetInterface(string name)
    {
      return this.GetInterface(name, false);
    }

    public abstract Type GetInterface(string name, bool ignoreCase);

    public abstract Type[] GetInterfaces();

    public virtual Type[] FindInterfaces(TypeFilter filter, object filterCriteria)
    {
      if (filter == null)
        throw new ArgumentNullException("filter");
      Type[] interfaces = this.GetInterfaces();
      int length = 0;
      for (int index = 0; index < interfaces.Length; ++index)
      {
        if (!filter(interfaces[index], filterCriteria))
          interfaces[index] = (Type) null;
        else
          ++length;
      }
      if (length == interfaces.Length)
        return interfaces;
      Type[] typeArray = new Type[length];
      int num = 0;
      for (int index = 0; index < interfaces.Length; ++index)
      {
        if (interfaces[index] != (Type) null)
          typeArray[num++] = interfaces[index];
      }
      return typeArray;
    }

    public EventInfo GetEvent(string name)
    {
      return this.GetEvent(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract EventInfo GetEvent(string name, BindingFlags bindingAttr);

    public virtual EventInfo[] GetEvents()
    {
      return this.GetEvents(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract EventInfo[] GetEvents(BindingFlags bindingAttr);

    public PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      else
        return this.GetPropertyImpl(name, bindingAttr, binder, returnType, types, modifiers);
    }

    public PropertyInfo GetProperty(string name, Type returnType, Type[] types, ParameterModifier[] modifiers)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      else
        return this.GetPropertyImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, returnType, types, modifiers);
    }

    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public PropertyInfo GetProperty(string name, BindingFlags bindingAttr)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      else
        return this.GetPropertyImpl(name, bindingAttr, (Binder) null, (Type) null, (Type[]) null, (ParameterModifier[]) null);
    }

    public PropertyInfo GetProperty(string name, Type returnType, Type[] types)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      else
        return this.GetPropertyImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, returnType, types, (ParameterModifier[]) null);
    }

    public PropertyInfo GetProperty(string name, Type[] types)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (types == null)
        throw new ArgumentNullException("types");
      else
        return this.GetPropertyImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, (Type) null, types, (ParameterModifier[]) null);
    }

    public PropertyInfo GetProperty(string name, Type returnType)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (returnType == (Type) null)
        throw new ArgumentNullException("returnType");
      else
        return this.GetPropertyImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, returnType, (Type[]) null, (ParameterModifier[]) null);
    }

    internal PropertyInfo GetProperty(string name, BindingFlags bindingAttr, Type returnType)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      if (returnType == (Type) null)
        throw new ArgumentNullException("returnType");
      else
        return this.GetPropertyImpl(name, bindingAttr, (Binder) null, returnType, (Type[]) null, (ParameterModifier[]) null);
    }

    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public PropertyInfo GetProperty(string name)
    {
      if (name == null)
        throw new ArgumentNullException("name");
      else
        return this.GetPropertyImpl(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public, (Binder) null, (Type) null, (Type[]) null, (ParameterModifier[]) null);
    }

    protected abstract PropertyInfo GetPropertyImpl(string name, BindingFlags bindingAttr, Binder binder, Type returnType, Type[] types, ParameterModifier[] modifiers);

    public abstract PropertyInfo[] GetProperties(BindingFlags bindingAttr);

    public PropertyInfo[] GetProperties()
    {
      return this.GetProperties(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public Type[] GetNestedTypes()
    {
      return this.GetNestedTypes(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract Type[] GetNestedTypes(BindingFlags bindingAttr);

    public Type GetNestedType(string name)
    {
      return this.GetNestedType(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract Type GetNestedType(string name, BindingFlags bindingAttr);

    public MemberInfo[] GetMember(string name)
    {
      return this.GetMember(name, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public virtual MemberInfo[] GetMember(string name, BindingFlags bindingAttr)
    {
      return this.GetMember(name, MemberTypes.Constructor | MemberTypes.Event | MemberTypes.Field | MemberTypes.Method | MemberTypes.Property | MemberTypes.TypeInfo | MemberTypes.NestedType, bindingAttr);
    }

    public virtual MemberInfo[] GetMember(string name, MemberTypes type, BindingFlags bindingAttr)
    {
      throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
    }

    public MemberInfo[] GetMembers()
    {
      return this.GetMembers(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
    }

    public abstract MemberInfo[] GetMembers(BindingFlags bindingAttr);

    [SecuritySafeCritical]
    public virtual MemberInfo[] GetDefaultMembers()
    {
      throw new NotImplementedException();
    }

    public virtual MemberInfo[] FindMembers(MemberTypes memberType, BindingFlags bindingAttr, MemberFilter filter, object filterCriteria)
    {
      MethodInfo[] methodInfoArray = (MethodInfo[]) null;
      ConstructorInfo[] constructorInfoArray = (ConstructorInfo[]) null;
      FieldInfo[] fieldInfoArray = (FieldInfo[]) null;
      PropertyInfo[] propertyInfoArray = (PropertyInfo[]) null;
      EventInfo[] eventInfoArray = (EventInfo[]) null;
      Type[] typeArray = (Type[]) null;
      int length = 0;
      if ((memberType & MemberTypes.Method) != (MemberTypes) 0)
      {
        methodInfoArray = this.GetMethods(bindingAttr);
        if (filter != null)
        {
          for (int index = 0; index < methodInfoArray.Length; ++index)
          {
            if (!filter((MemberInfo) methodInfoArray[index], filterCriteria))
              methodInfoArray[index] = (MethodInfo) null;
            else
              ++length;
          }
        }
        else
          length += methodInfoArray.Length;
      }
      if ((memberType & MemberTypes.Constructor) != (MemberTypes) 0)
      {
        constructorInfoArray = this.GetConstructors(bindingAttr);
        if (filter != null)
        {
          for (int index = 0; index < constructorInfoArray.Length; ++index)
          {
            if (!filter((MemberInfo) constructorInfoArray[index], filterCriteria))
              constructorInfoArray[index] = (ConstructorInfo) null;
            else
              ++length;
          }
        }
        else
          length += constructorInfoArray.Length;
      }
      if ((memberType & MemberTypes.Field) != (MemberTypes) 0)
      {
        fieldInfoArray = this.GetFields(bindingAttr);
        if (filter != null)
        {
          for (int index = 0; index < fieldInfoArray.Length; ++index)
          {
            if (!filter((MemberInfo) fieldInfoArray[index], filterCriteria))
              fieldInfoArray[index] = (FieldInfo) null;
            else
              ++length;
          }
        }
        else
          length += fieldInfoArray.Length;
      }
      if ((memberType & MemberTypes.Property) != (MemberTypes) 0)
      {
        propertyInfoArray = this.GetProperties(bindingAttr);
        if (filter != null)
        {
          for (int index = 0; index < propertyInfoArray.Length; ++index)
          {
            if (!filter((MemberInfo) propertyInfoArray[index], filterCriteria))
              propertyInfoArray[index] = (PropertyInfo) null;
            else
              ++length;
          }
        }
        else
          length += propertyInfoArray.Length;
      }
      if ((memberType & MemberTypes.Event) != (MemberTypes) 0)
      {
        eventInfoArray = this.GetEvents();
        if (filter != null)
        {
          for (int index = 0; index < eventInfoArray.Length; ++index)
          {
            if (!filter((MemberInfo) eventInfoArray[index], filterCriteria))
              eventInfoArray[index] = (EventInfo) null;
            else
              ++length;
          }
        }
        else
          length += eventInfoArray.Length;
      }
      if ((memberType & MemberTypes.NestedType) != (MemberTypes) 0)
      {
        typeArray = this.GetNestedTypes(bindingAttr);
        if (filter != null)
        {
          for (int index = 0; index < typeArray.Length; ++index)
          {
            if (!filter((MemberInfo) typeArray[index], filterCriteria))
              typeArray[index] = (Type) null;
            else
              ++length;
          }
        }
        else
          length += typeArray.Length;
      }
      MemberInfo[] memberInfoArray = new MemberInfo[length];
      int num = 0;
      if (methodInfoArray != null)
      {
        for (int index = 0; index < methodInfoArray.Length; ++index)
        {
          if (methodInfoArray[index] != (MethodInfo) null)
            memberInfoArray[num++] = (MemberInfo) methodInfoArray[index];
        }
      }
      if (constructorInfoArray != null)
      {
        for (int index = 0; index < constructorInfoArray.Length; ++index)
        {
          if (constructorInfoArray[index] != (ConstructorInfo) null)
            memberInfoArray[num++] = (MemberInfo) constructorInfoArray[index];
        }
      }
      if (fieldInfoArray != null)
      {
        for (int index = 0; index < fieldInfoArray.Length; ++index)
        {
          if (fieldInfoArray[index] != (FieldInfo) null)
            memberInfoArray[num++] = (MemberInfo) fieldInfoArray[index];
        }
      }
      if (propertyInfoArray != null)
      {
        for (int index = 0; index < propertyInfoArray.Length; ++index)
        {
          if (propertyInfoArray[index] != (PropertyInfo) null)
            memberInfoArray[num++] = (MemberInfo) propertyInfoArray[index];
        }
      }
      if (eventInfoArray != null)
      {
        for (int index = 0; index < eventInfoArray.Length; ++index)
        {
          if (eventInfoArray[index] != (EventInfo) null)
            memberInfoArray[num++] = (MemberInfo) eventInfoArray[index];
        }
      }
      if (typeArray != null)
      {
        for (int index = 0; index < typeArray.Length; ++index)
        {
          if (typeArray[index] != (Type) null)
            memberInfoArray[num++] = (MemberInfo) typeArray[index];
        }
      }
      return memberInfoArray;
    }

    public virtual Type[] GetGenericParameterConstraints()
    {
      if (!this.IsGenericParameter)
        throw new InvalidOperationException(Environment.GetResourceString("Arg_NotGenericParameter"));
      else
        throw new InvalidOperationException();
    }

    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    protected virtual bool IsValueTypeImpl()
    {
      return this.IsSubclassOf((Type) RuntimeType.ValueType);
    }

    protected abstract TypeAttributes GetAttributeFlagsImpl();

    protected abstract bool IsArrayImpl();

    protected abstract bool IsByRefImpl();

    protected abstract bool IsPointerImpl();

    protected abstract bool IsPrimitiveImpl();

    protected abstract bool IsCOMObjectImpl();

    public virtual Type MakeGenericType(params Type[] typeArguments)
    {
      throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
    }

    protected virtual bool IsContextfulImpl()
    {
      return typeof (ContextBoundObject).IsAssignableFrom(this);
    }

    protected virtual bool IsMarshalByRefImpl()
    {
      return typeof (MarshalByRefObject).IsAssignableFrom(this);
    }

    internal virtual bool HasProxyAttributeImpl()
    {
      return false;
    }

    public abstract Type GetElementType();

    public virtual Type[] GetGenericArguments()
    {
      throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
    }

    public virtual Type GetGenericTypeDefinition()
    {
      throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
    }

    protected abstract bool HasElementTypeImpl();

    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    internal virtual Type GetRootElementType()
    {
      Type type = this;
      while (type.HasElementType)
        type = type.GetElementType();
      return type;
    }

    public virtual string[] GetEnumNames()
    {
      if (!this.IsEnum)
        throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
      string[] enumNames;
      Array enumValues;
      this.GetEnumData(out enumNames, out enumValues);
      return enumNames;
    }

    public virtual Array GetEnumValues()
    {
      if (!this.IsEnum)
        throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
      else
        throw new NotImplementedException();
    }

    private Array GetEnumRawConstantValues()
    {
      string[] enumNames;
      Array enumValues;
      this.GetEnumData(out enumNames, out enumValues);
      return enumValues;
    }

    private void GetEnumData(out string[] enumNames, out Array enumValues)
    {
      FieldInfo[] fields = this.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
      object[] objArray = new object[fields.Length];
      string[] strArray = new string[fields.Length];
      for (int index = 0; index < fields.Length; ++index)
      {
        strArray[index] = fields[index].Name;
        objArray[index] = fields[index].GetRawConstantValue();
      }
      IComparer comparer = (IComparer) Comparer.Default;
      for (int index1 = 1; index1 < objArray.Length; ++index1)
      {
        int index2 = index1;
        string str = strArray[index1];
        object y = objArray[index1];
        bool flag = false;
        while (comparer.Compare(objArray[index2 - 1], y) > 0)
        {
          strArray[index2] = strArray[index2 - 1];
          objArray[index2] = objArray[index2 - 1];
          --index2;
          flag = true;
          if (index2 == 0)
            break;
        }
        if (flag)
        {
          strArray[index2] = str;
          objArray[index2] = y;
        }
      }
      enumNames = strArray;
      enumValues = (Array) objArray;
    }

    public virtual Type GetEnumUnderlyingType()
    {
      if (!this.IsEnum)
        throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
      FieldInfo[] fields = this.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
      if (fields == null || fields.Length != 1)
        throw new ArgumentException(Environment.GetResourceString("Argument_InvalidEnum"), "enumType");
      else
        return fields[0].FieldType;
    }

    public virtual bool IsEnumDefined(object value)
    {
      if (value == null)
        throw new ArgumentNullException("value");
      if (!this.IsEnum)
        throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
      Type t = value.GetType();
      if (t.IsEnum)
      {
        if (!t.IsEquivalentTo(this))
          throw new ArgumentException(Environment.GetResourceString("Arg_EnumAndObjectMustBeSameType", (object) t.ToString(), (object) this.ToString()));
        else
          t = t.GetEnumUnderlyingType();
      }
      if (t == typeof (string))
      {
        if (Array.IndexOf<object>((object[]) this.GetEnumNames(), value) >= 0)
          return true;
        else
          return false;
      }
      else
      {
        if (!Type.IsIntegerType(t))
          throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_UnknownEnumType"));
        Type enumUnderlyingType = this.GetEnumUnderlyingType();
        if (enumUnderlyingType.GetTypeCodeImpl() == t.GetTypeCodeImpl())
          return Type.BinarySearch(this.GetEnumRawConstantValues(), value) >= 0;
        throw new ArgumentException(Environment.GetResourceString("Arg_EnumUnderlyingTypeAndObjectMustBeSameType", (object) t.ToString(), (object) enumUnderlyingType.ToString()));
      }
    }

    public virtual string GetEnumName(object value)
    {
      if (value == null)
        throw new ArgumentNullException("value");
      if (!this.IsEnum)
        throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnum"), "enumType");
      Type type = value.GetType();
      if (!type.IsEnum && !Type.IsIntegerType(type))
        throw new ArgumentException(Environment.GetResourceString("Arg_MustBeEnumBaseTypeOrEnum"), "value");
      int index = Type.BinarySearch(this.GetEnumRawConstantValues(), value);
      if (index >= 0)
        return this.GetEnumNames()[index];
      else
        return (string) null;
    }

    private static int BinarySearch(Array array, object value)
    {
      ulong[] array1 = new ulong[array.Length];
      for (int index = 0; index < array.Length; ++index)
        array1[index] = Enum.ToUInt64(array.GetValue(index));
      ulong num = Enum.ToUInt64(value);
      return Array.BinarySearch<ulong>(array1, num);
    }

    internal static bool IsIntegerType(Type t)
    {
      if (!(t == typeof (int)) && !(t == typeof (short)) && (!(t == typeof (ushort)) && !(t == typeof (byte))) && (!(t == typeof (sbyte)) && !(t == typeof (uint)) && !(t == typeof (long))))
        return t == typeof (ulong);
      else
        return true;
    }

    [ComVisible(true)]
    public virtual bool IsSubclassOf(Type c)
    {
      Type type = this;
      if (type == c)
        return false;
      for (; type != (Type) null; type = type.BaseType)
      {
        if (type == c)
          return true;
      }
      return false;
    }

    [SecuritySafeCritical]
    public virtual bool IsInstanceOfType(object o)
    {
      if (o == null)
        return false;
      else
        return this.IsAssignableFrom(o.GetType());
    }

    [SecuritySafeCritical]
    public virtual bool IsAssignableFrom(Type c)
    {
      if (c == (Type) null)
        return false;
      if (this == c)
        return true;
      RuntimeType runtimeType = this.UnderlyingSystemType as RuntimeType;
      if (runtimeType != (RuntimeType) null)
        return runtimeType.IsAssignableFrom(c);
      if (c.IsSubclassOf(this))
        return true;
      if (this.IsInterface)
        return c.ImplementInterface(this);
      if (!this.IsGenericParameter)
        return false;
      foreach (Type type in this.GetGenericParameterConstraints())
      {
        if (!type.IsAssignableFrom(c))
          return false;
      }
      return true;
    }

    public virtual bool IsEquivalentTo(Type other)
    {
      return this == other;
    }

    internal bool ImplementInterface(Type ifaceType)
    {
      for (Type type = this; type != (Type) null; type = type.BaseType)
      {
        Type[] interfaces = type.GetInterfaces();
        if (interfaces != null)
        {
          for (int index = 0; index < interfaces.Length; ++index)
          {
            if (interfaces[index] == ifaceType || interfaces[index] != (Type) null && interfaces[index].ImplementInterface(ifaceType))
              return true;
          }
        }
      }
      return false;
    }

    public override string ToString()
    {
      return "Type: " + this.Name;
    }

    public static Type[] GetTypeArray(object[] args)
    {
      if (args == null)
        throw new ArgumentNullException("args");
      Type[] typeArray = new Type[args.Length];
      for (int index = 0; index < typeArray.Length; ++index)
      {
        if (args[index] == null)
          throw new ArgumentNullException();
        typeArray[index] = args[index].GetType();
      }
      return typeArray;
    }

    public override bool Equals(object o)
    {
      if (o == null)
        return false;
      else
        return this.Equals(o as Type);
    }

    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public virtual bool Equals(Type o)
    {
      if (o == null)
        return false;
      else
        return object.ReferenceEquals((object) this.UnderlyingSystemType, (object) o.UnderlyingSystemType);
    }

    [TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
    public override int GetHashCode()
    {
      Type underlyingSystemType = this.UnderlyingSystemType;
      if (!object.ReferenceEquals((object) underlyingSystemType, (object) this))
        return underlyingSystemType.GetHashCode();
      else
        return base.GetHashCode();
    }

    [ComVisible(true)]
    public virtual InterfaceMapping GetInterfaceMap(Type interfaceType)
    {
      throw new NotSupportedException(Environment.GetResourceString("NotSupported_SubclassOverride"));
    }

    void _Type.GetTypeInfoCount(out uint pcTInfo)
    {
      throw new NotImplementedException();
    }

    void _Type.GetTypeInfo(uint iTInfo, uint lcid, IntPtr ppTInfo)
    {
      throw new NotImplementedException();
    }

    void _Type.GetIDsOfNames([In] ref Guid riid, IntPtr rgszNames, uint cNames, uint lcid, IntPtr rgDispId)
    {
      throw new NotImplementedException();
    }

    void _Type.Invoke(uint dispIdMember, [In] ref Guid riid, uint lcid, short wFlags, IntPtr pDispParams, IntPtr pVarResult, IntPtr pExcepInfo, IntPtr puArgErr)
    {
      throw new NotImplementedException();
    }
  }
}
